package pack0711;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.List;

//演示对象输出字节流
public class ObjectOutputStreamDemo {

    public static void main(String[] args) throws Exception {
        User user1=new User("张无忌",20);
        User user2=new User("郭靖",25);
        User user3=new User("乔峰",21);

        List<User>list=new ArrayList<>();
        list.add(user1);
        list.add(user2);
        list.add(user3);

        //创建对象输出流
        ObjectOutputStream oos=new ObjectOutputStream(new FileOutputStream("b.txt"));

//        oos.writeObject(user1);
//        oos.writeObject(user2);
//        oos.writeObject(user3);

        oos.writeObject(list);

        oos.close();



    }
}
